package com.xmh.reptile.entity;

import java.util.Date;
import java.math.BigDecimal;
import java.util.Map;
import java.util.HashMap;
import com.alibaba.fastjson.JSONObject;
import java.sql.Timestamp;
import lombok.Data;
import java.io.Serializable;

@Data
public class VideoEntity implements Serializable {

	/**
	 * 版本号
	 * 表备注：
	 */
	public static final long serialVersionUID = 2416217197983932288L;

	/**
	 *
	 */
	private Integer id;

	/**
	 *
	 */
	private String name;

	/**
	 *
	 */
	private String bucketName;

	/**
	 *
	 */
	private BigDecimal price;

	/**
	 *
	 */
	private String objectKey;

	/**
	 *
	 */
	private Double size;

	/**
	 *
	 */
	private Date updateDate;

	/**
	 *
	 */
	private Date createDate;

	@SuppressWarnings("unchecked")
	public VideoEntity(String json) {
		this(JSONObject.parseObject(json, Map.class));
	}

	public VideoEntity() {}

	public VideoEntity(Map<String, Object> map) {
		if (map == null || map.isEmpty()) {
			return;
		}

		if (map.get("id") != null) {
			id = Integer.valueOf(String.valueOf(map.get("id")));
		}

		name = (String) map.get("name");

		bucketName = (String) map.get("bucketName");

		if (map.get("price") != null) {
			price = new BigDecimal(String.valueOf(map.get("price")));
		}

		objectKey = (String) map.get("objectKey");

		if (map.get("size") != null) {
			size = Double.valueOf(String.valueOf(map.get("size")));
		}

		Object updateDateobj = map.get("updateDate");
		if (updateDateobj != null) {
			if (updateDateobj instanceof Date) {
				updateDate = (Date) updateDateobj;
			} else {
				updateDate = new Date((long) updateDateobj);
			}
		}

		Object createDateobj = map.get("createDate");
		if (createDateobj != null) {
			if (createDateobj instanceof Date) {
				createDate = (Date) createDateobj;
			} else {
				createDate = new Date((long) createDateobj);
			}
		}

	}

    public Map toMap() {
        Map map = new HashMap();
        map.put("id", id);
        map.put("name", name);
        map.put("bucketName", bucketName);
        map.put("price", price);
        map.put("objectKey", objectKey);
        map.put("size", size);
        map.put("updateDate", updateDate);
        map.put("createDate", createDate);
        return map;
    }


}